import { Root } from 'native-base';
import React, { BaseSyntheticEvent } from 'react';
import { Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
import { Icon } from 'react-native-elements';

interface D {
	d: string;
	data1: Array<{ class_name: string }>;
	data2: Array<{ headimg: string, student_name: string, student_no: string }>;
	data3: Array<{ phone: string }>;
}
export default function tpl(a: <T>(action: string, ...args: unknown[]) => ((ev: BaseSyntheticEvent<T>) => void), s: (...class_names: string[]) => {}, d: (d: string) => string | unknown[] | D) {
	const dt = d('data') as D;
	// console.log(dt, '---------data--------');
	if (dt) {
		if (dt.d === '0') {
			return (
				<Root>
					<View>
						<ScrollView style={{ marginBottom: 20 }}>
							<View>
								<View style={s('list1')}>
									<View style={s('rowC')}>
										<Image source={dt.data2[0].headimg ? { uri: dt.data2[0].headimg } : require('../../imgs/nan.jpg')} style={s('tu1')} />
										<Text style={s('text1')}>{dt.data2[0].student_name}</Text>
										<Text style={s('text2')}>{dt.data1[0].class_name}</Text>
									</View>
									<View style={s('rowC')}>
										<View style={s('rowC')}>
											<View style={s('btn1', 'border1e')}>
												<Text onPress={a('a002', dt.data2[0].student_no)} style={s('btext')}>手动签到</Text>
											</View>
											<View style={s('icon')}>
												<TouchableOpacity onPress={a('a003', dt.data3[0].phone)}>
													<Icon name="call" color="#ffffff" size={20}></Icon>
												</TouchableOpacity>
											</View>
										</View>
									</View>
								</View>
							</View>
						</ScrollView>
					</View>
				</Root>
			);
		} else {
			return (<View><Text style={s('btext')}>已签到</Text></View>);
		}
	} else {
		return (<View></View>);
	}
}
